Skip to content

transformation(): fix the sign of the FFT fallback translation (split from #1426) - #1436

Merged
mfitzasp merged 1 commit into
rzellem:michael_fitzgeralds_wonderful_branch_of_magicfrom
opusbuilds:fix-fft-alignment-sign
Dec 2, 2026
Merged

mfitzasp merged 1 commit into
rzellem:michael_fitzgeralds_wonderful_branch_of_magicfrom
opusbuilds:fix-fft-alignment-sign

Conversation

@opusbuilds

Copy link
Copy Markdown

Split out of #1426 (commit 8f30f97) so it can land on its own, as discussed with Michael.

The bug. In transformation(), the FFT fallback calls phase_cross_correlation(roi_current, roi_reference), whose shift moves the reference onto the current frame. Every caller applies the returned transform to reference-frame pixels to get current-frame pixels, and the astroalign and imreg_dft branches already return transforms in that direction. The FFT branch negated the shift, so it pointed the wrong way: for a field moved by (+10, +5) px, a star at (100, 80) was sent to (90, 75) instead of (110, 85).

When it matters. Only when the FFT translation is the transform that gets used: in practice the last-resort fallback on the hardest frames, after the feature-matching stages fail (it fired on 1-8 frames in 5 of my 434 MicroObservatory run logs). The "high-confidence FFT" shortcut almost never triggers, because the default normalisation reports error 1.0 even for an exact synthetic shift (skimage 0.26).

Change. One line (translation=[shift[1], shift[0]]) plus a comment, and tests/test_fft_alignment_sign.py, which calls transformation() on a synthetic (+10, +5) field with astroalign and imreg_dft forced to fail. It passes with the fix and fails on the current tip.

phase_cross_correlation(roi_current, roi_reference) returns the shift that moves the
reference onto the current frame; the transform must map reference pixels onto the
current frame (as the astroalign and imreg_dft branches do), so the shift is used with a
positive sign. The negated sign sent a star at (100, 80) in a field moved by (+10, +5)
to (90, 75) instead of (110, 85). Fix originally in rzellem#1426 (commit 8f30f97), split out
so it can land on its own; regression test exercises transformation() with the other
branches forced to fail.
@mfitzasp
mfitzasp merged commit 7824fa8 into rzellem:michael_fitzgeralds_wonderful_branch_of_magic Dec 2, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants